export default function (url: String, options: any) {
    const runtimeConfig = useRuntimeConfig()
    let BASE_URL = runtimeConfig.public.BaseUrl
    return useFetch(BASE_URL + url, {
        ...options,
        onRequest({ request, options: any }) {
            // Set the request headers
            options.headers = options.headers || {}
            // options.headers.authorization = 'cwiyc'
            options.method = options.method || 'get'
            options.headers['Content-Type'] = options.headers['Content-Type'] || 'application/json;charset=utf-8';
            // console.log(options)
        },
        onRequestError({ request, options, error }) {
            // Handle the request errors
            return Promise.reject(error)
        },
        onResponse({ request, response, options }) {
            // Process the response data
            // console.log(response)
            return response._data
        },
        onResponseError({ request, response, options }) {
            // Handle the response errors
            Promise.reject(response)
        }
    })
}